package cn.edu.gduf.luowowo.common.util;

import lombok.Getter;

/**
 * 操作redis中的key的枚举类
 */
@Getter
public enum RedisKeys {
    //酒店的收藏,这个id是用户的id
    USER_HOTEL_FAVOR_ID("user_hotel_favor_id", -1),

    //景点的去过
    SCENIC_STATIS_VO_BEEN("scenic_statis_vo_been",-1),
    //景点统计对象
    SCENIC_STATIS_VO("scenic_statis_vo",-1 ),
    //景点的收藏
    SCENIC_STATIS_VO_FAVOR("scenic_statis_vo_favor",-1),

    //有技术局统计对象
    TRAVEL_STATIS_VO("travel_statis_vo",-1),

    //游记收藏
    USER_FAVOR_TRAVEL_ID("user_favor_travel_id",-1),

    //攻略收藏
    USER_FAVOR_STRATEGY_ID("user_favor_strategy_id",-1),

    //国内/国外热门攻略推荐
    STARTEGY_ZSET_SORT_COMMEND("startegy_zset_sort_commend", -1),

    //热门攻略推荐 zset，不区分国内外
    STARTEGY_ZSET_SORT_HOT("startegy_zset_sort_hot", -1),

    //点赞
    STARTEGY_STATIS_THUMBSUP("startegy_statis_thumbsup", -1),

    //数据统计对象，-1表示没有时效性
    STARTEGY_STATIS_VO("startegy_statis_vo", -1),

    //收藏，-1表示没有时效性
    STARTEGY_STATIS_VO_FAVOR("startegy_statis_vo_favor", -1),

    //短信验证码的有效时间
    VERIFY_CODE("verify_code", Consts.VERIY_CODE_VALID_TIME * 60),

    //短信验证码是否发送(作用-控制短信验证码发送频率)
    VERIFY_CODE_TIME("verify_code_time", Consts.VERIY_CODE_TIME * 60),

    //用户登录的有效时间
    USER_TOKEN("user_token", Consts.USER_INFO_TOKEN_VAI_TIME * 60),

    //问答数据统计对象
    QUESTION_STATIS_VO("question_statis_vo", -1),

    //问答关注
    QUESTION_STATIS_FOCUS("question_statis_focus", -1),

    //问答顶
    QUESTION_STATIS_DING("question_statis_ding", -1),

    //金牌回答，问答对象被设置为金牌
    QUESTION_ZSET_SORT_GOLD ("question_zset_sort_gold ", -1),

    //问答 顶，问答对象被顶的次数排行
    QUESTION_ZSET_SORT_DING("question_zset_sort_ding", -1),

    //问答数,统计问答对象下的回答数，排行
    QUESTION_ZSET_SORT_ANSWER("question_zset_sort_answer", -1);


    private String prefix; //前缀
    private Integer time;

    private RedisKeys(String prefix, Integer time) {
        this.prefix = prefix;
        this.time = time;
    }

    /**
     * 这个方法就是为了来拼接redis的key，使用...可变参数增加灵活性
     */
    public String join(String... texts) {
        StringBuilder builder = new StringBuilder();
        builder.append(this.prefix);
        for (String text : texts) {
            builder.append(":").append(text);
        }
        return builder.toString();
    }

}
